import jieba
from matplotlib import pyplot

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from wordcloud import WordCloud, ImageColorGenerator
import jieba
# from imageio import imread

stopwords_path = './stopwords_cn_en.txt'

text = ["我们一起加油啊","十年之后要有很多好的事物是属于我们的",
        "哈哈哈哈，小傻瓜","是否你是一只猪"]

img=Image.open(r"./heart.jpg")
imask=np.array(img)
wc = WordCloud(font_path="C:\Windows\Fonts\STZHONGS.TTF", max_words=2000,
               background_color="white",
               mask=imask,#遮罩
               max_font_size=100, random_state=42, width=1000, height=860, margin=2,)

item=""
for i in range(0,len(text)):
    item=item+text[i]

cut=jieba.cut(item)
result=" ".join(cut)

wc.generate(result)


# show

plt.figure()
# recolor wordcloud and show
plt.imshow(wc, interpolation="bilinear")
plt.axis("off")
# plt.show()

plt.savefig("./logo.jpg")








# ----------------------------------
# item=""
# for i in range(0,len(text)):
#     item=item+text[i]
#
# cut=jieba.cut(item)
# result=" ".join(cut)
# print(result)
# print(len(result.split(" ")))